package com.yc.goods.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yc.vo.GoodsVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface GoodsVODao extends BaseMapper<GoodsVO> {
    /**
     * 分页分组查询数据
     * @param tno
     * @param page
     * @param pagesize
     * @return
     */
    @Select("select t.tno,tname,pic,status,gno,gname,price," +
            "intro,balance,pics,unit,qperied,weight,descr from goodstype t inner " +
            "join goodsinfo g on g.tno=t.tno where 1=1 AND T.TNO=#{tno} " +
            "ORDER BY g.gno LIMIT #{page},#{pagesize}")
    List<GoodsVO> findByPage(Integer tno, Integer page, Integer pagesize);

    /**
     * 根据类型编号统计数据总量
     * @param tno
     * @return
     */
    @Select("select count(*) from goodstype t inner join goodsinfo g on g.tno = t.tno where t.tno = #{tno}")
    int totalPage(@Param("tno") Integer tno);
}
